package demogo

func QuickSort(a []int) {
	n := len(a)
	if n <= 1 {
		return
	}
	pivot := a[0]
	left := 0
	right := n - 1
	for i := 1; i <= right; {
		if a[i] > pivot {
			a[i], a[right] = a[right], a[i]
			right--
		} else {
			a[i], a[left] = a[left], a[i]
			left++
			i++
		}
	}
	QuickSort(a[:left])
	QuickSort(a[left+1:])
}
